package com.liu.es.test;

import org.apache.http.HttpHost;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.xcontent.XContentType;

/**
 * 删除文档的对象:DeleteRequest
 */
public class ESTest_Doc_Delete {
    public static void main(String[] args) throws Exception {

        RestHighLevelClient esClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost("localhost", 9200, "http"))
        );
        //创建删除操作对象
        DeleteRequest re = new DeleteRequest();
        re.index("user").id("1001");

        //将删除操作发送至服务器
        DeleteResponse delete = esClient.delete(re, RequestOptions.DEFAULT);
        System.out.println(delete.toString());

        esClient.close();
    }
}
